/**
 * @author Paulo Faria Reis
 * @created 15 Mar 2012
 *
 */
package controller;

import java.io.IOException;

import networkoperations.FileSender;
import networkoperations.MulticastListener;
import networkoperations.MulticastReceiver;
import controller.DataStore;

/**
 * @author Paulo Faria Reis
 */
public class StartP2P {

   /**
    * @param args
    * @throws IOException 
    * @throws InterruptedException 
    */
   public static void main(String[] args) throws InterruptedException {
	DataStore dataStorage = new DataStore();
	dataStorage.processArgs(args);

	// Start the control and data Listeners and UI Threads.
	Thread mcl = new Thread(new MulticastListener(dataStorage), "Control");
	Thread mcr = new Thread(new MulticastReceiver(dataStorage), "Data");
	Thread fs = new Thread(new FileSender(dataStorage), "FileSender");
	Thread ui = new Thread(new TextUI(dataStorage), "UI");
	
	mcr.start();
	mcl.start();
	ui.start();
	fs.start();
	
	ui.join();
   }
}
